type CallbackFunction = (...args: any[]) => void;

export function debounce(callback: CallbackFunction, delay: number = 500): (...args: any[]) => void {
    let timer: ReturnType<typeof setTimeout>;
    return function(...args: any[]) {
        clearTimeout(timer);
        timer = setTimeout(() => {
            callback(...args);
        }, delay);
    };
}
